<?php
require_once('Mobile_Detect.php');
require_once('utils.php');
$detect = new Mobile_Detect();

$industries = array();
foreach($lang->home->children() as $element => $value){
	if (strpos(((string)$element), "info") !== false && (string)$element !== 'defaultinfo') {
		array_push($industries, $element);	
	}
}

$directory = $_SERVER["DOCUMENT_ROOT"]."/img/mobile/demos/".$_GET['industry']."/";
$images = glob($directory."*.jpg");
$slidesCount = count($images);
$currentSlide = isset($_GET['slide']) ? $_GET['slide'] : 1;
$currentSlideClass = "slide".$currentSlide;
?>
<!DOCTYPE html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="minimum-scale=1, width=device-width, maximum-scale=1, initial-scale=1, user-scalable=0" />
    <title><?php echo($lang->home->title) ?></title>
    <meta name="description" content="<?php echo($lang->home->description) ?>" />
    <meta property="fb:app_id" content="<?php echo($lang->home->fbapp_id) ?>" /> 
    <meta property="og:type" content="website" /> 
    <meta property="og:title" content="<?php echo($lang->home->ogtitle) ?>" /> 
    <meta property="og:image" content="<?php echo($_SERVER['HTTP_HOST'].$lang->home->ogimage) ?>" />  
    <meta property="og:description" content="<?php echo($lang->home->ogdescription) ?>" /> 
    <meta property="og:url" content="<?php echo(full_url()) ?>">
    
    <link rel="stylesheet" href="css/jquery.mobile.structure-1.0.1.min.css" />
    <link rel="stylesheet" href="css/mobile.css" />
	<link rel="stylesheet" href="css/fonts/fonts.css" />
</head>
<body class="gradient mobiledemo">
	<div data-role="page" id="<?php echo($_GET['industry'].$currentSlide) ?>" class="demo <?php if ($detect->isIPhone()) echo "iphone"; ?>" data-dom-cache="true" data-ajax="false" data-rel="external">
	    <div data-role="content">
	    	<div class="demo-image">
	    		<?php
	            $image = $images[$currentSlide-1];
	            $image = str_replace($directory, "", $image); 
	    		if ($currentSlide == $slidesCount) {
	    			printf('<a data-role="button" data-transition="pop reverse" href="mobile.php?industry=%s" class="close-demo-red ui-btn-right" data-url="%s"><span class="ui-btn-inner"></span></a>', $_GET['industry'], $_GET['industry']);
				}
				else {
					printf('<a data-role="button" data-transition="pop reverse" href="mobile.php?industry=%s" class="close-demo ui-btn-right" data-url="%s"><span class="ui-btn-inner"></span></a>', $_GET['industry'], $_GET['industry']);
				}
	            
	        	printf ('<div class="image" data-industry="%s" data-image="%s"><img src="../img/mobile/spinner.gif" /></div>', $_GET['industry'], $image);
				if ($currentSlide > 1)
				printf('<a class="prev" data-transition="slide reverse" href="%s?industry=%s&slide=%d" data-rel="page" data-url="%s%d" data-prefetch>Prev</a>', $_SERVER['PHP_SELF'], $_GET['industry'], $currentSlide-1, $_GET['industry'], $currentSlide-1);
				
				if ($currentSlide == $slidesCount) {
					
					printf('<a href="includes/emailDialog.php" class="next" data-role="button" data-rel="dialog" data-inline="true" data-transition="fade">Next</a>');
				}
				else {
					printf('<a class="next" data-transition="slide" href="%s?industry=%s&slide=%d" data-rel="page" data-url="%s%d" data-prefetch>Next</a>', $_SERVER['PHP_SELF'], $_GET['industry'], $currentSlide+1, $_GET['industry'], $currentSlide+1);
				}
				
	        	?>
		    </div>
	    </div>
	    <div data-theme="" data-role="footer" data-fullscreen="true" id="footer" data-position="fixed" class="gradient ui-footer">
	    	<div class="copy">
	    		<div class="counter"><?php printf ('%d/%d', $currentSlide, $slidesCount); ?></div>
	    		<h1><?php echo($lang->demos->$_GET['industry']->$currentSlideClass->h1) ?></h1>
	            <span class="text"><?php echo($lang->demos->$_GET['industry']->$currentSlideClass->copy) ?></span>
	            <a href="includes/emailDialog.php" class="button-email-demo" data-role="button" data-rel="dialog" data-inline="true" data-transition="fade"><span class="ui-btn-inner"><?php echo($lang->buttons->emaildemo) ?></span></a>
	        </div>
	    </div>
	</div>
	
	<div data-role="dialog" id="popup" data-url="orientate" data-dom-cache="true" class="ui-dialog">
		<div data-role="content">
			<div class="dialog">
				<h1><?php echo($lang->mobile->dialog->h1) ?></h1>

				<div class="gradient">
					<div class="copy"><?php echo($lang->mobile->dialog->landscape) ?></div>
				</div>
			</div>
		</div>
	</div>
			
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
    <script>window.jQuery || document.write('<script src="js/libs/jquery-1.7.1.min.js"><\/script>')</script>
    <script src="//www.google.com/jsapi"></script>
    <script src="js/plugins.js"></script>
	<script src="js/libs/jquery.touchwipe.min.js"></script>
	<script src="js/mobile.js"></script>
    <?php include_once($_SERVER["DOCUMENT_ROOT"].'/includes/ga.php') ?>    
</body>
</html>
